<template>
        <div class="zxyA">
          <el-card>
          <div style="font-size: 24px; color: #000000">设置密码</div>
          <el-divider></el-divider>
          <div style="padding-top:10px;padding-bottom:10px;">
              <div style="padding-top:10px;padding-bottom:10px;">
                  <el-input v-model="inputA" placeholder="请输入密码" show-password></el-input>
              </div>
              <div style="padding-top:10px;padding-bottom:10px;">
                  <el-input v-model="inputB" placeholder="请再次输入密码" show-password></el-input>
              </div>
              <div class="wellA">
                  <div style="padding-top:10px;padding-bottom:10px;">
                    <el-button @click="savePwd()">保存密码</el-button>
                </div> 
            </div> 
              </div>  
              </el-card>             
        </div>
</template>

<script>
import { defineComponent, reactive, toRefs } from "vue";
import {Edit} from "@element-plus/icons";
import logo from "../assets/no_border.png";
import axios from "axios";
import qs from 'qs';
export default defineComponent({
  setup() {
    const state = reactive({
      logo,
      Edit,
      inputA:'',
      inputB:''
    });
    return {
      ...toRefs(state),
    };
  },
  methods: {
    goToModify(){
      this.$router.push("/personalcenterformodify");
    },
    savePwd(){
        let dataA={
            userID:this.$store.getters.userID,
            password1:this.inputA,
            password2:this.inputB
        }
        let data=qs.stringify(dataA)
        axios.post("setPwd/",data).then((res) => { 
          console.log(res.data);
          if (res.data.code==200){
              this.$message({ message: '设置密码成功', type: 'success' });
              this.$router.push("/");
          }
          else{
              this.$message.error(res.data.msg);
          }
        });
    }
  },
});
</script>


<style scoped>
.zxyA {
  margin-top: 30px;
  width: 600px;
  position: absolute;
  left: calc(50% - 300px);
  text-align: left;
}

</style>